% calculate seeds distance
% input: all seeds matrix
% output: 
% seeds_distance_total: the total distance of every seed to other seed
% distance_total: all seeds total distance
function [seeds_distance_total, distance_total] = calculate_seeds_distance(all_seeds_matrix)
% calculate the distance between every each seed to others

all_seeds_number = size(all_seeds_matrix, 1);
all_distance_matrix = zeros(all_seeds_number, all_seeds_number);
seeds_distance_total = zeros(1, all_seeds_number);

distance_total = 0;
for i = 1 : all_seeds_number
    for j = i : all_seeds_number
        all_distance_matrix(i,j) = distance(all_seeds_matrix(i,:), all_seeds_matrix(j,:));
    end
end
all_distance_matrix = all_distance_matrix + all_distance_matrix';

for d = 1 : all_seeds_number
    seeds_distance_total(d) = sum(all_distance_matrix(:,d));
    distance_total = distance_total + seeds_distance_total(d);
end
end

% calculate the distance between two vectors
function result = distance(ith_seed, jth_seed)
result = sqrt(sum((ith_seed - jth_seed).^2));
end